package com.sunwayworld.basemodule.common.asynctask.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import com.sunwayworld.framework.at.annotation.AuditTrailType;
import com.sunwayworld.framework.at.annotation.AuditTrailEntry;
import com.sunwayworld.framework.spring.annotation.GikamBean;

import com.sunwayworld.basemodule.common.asynctask.dao.LimsAsynctaskServerDao;
import com.sunwayworld.basemodule.common.asynctask.bean.LimsAsynctaskServerBean;
import com.sunwayworld.basemodule.common.asynctask.service.LimsAsynctaskServerService;
import com.sunwayworld.framework.context.ApplicationContextHelper;
import com.sunwayworld.framework.restful.data.RestJsonWrapperBean;

@Repository
@GikamBean
public class LimsAsynctaskServerServiceImpl implements LimsAsynctaskServerService {

    @Autowired
    private LimsAsynctaskServerDao limsAsynctaskServerDao;

    @Override
    @SuppressWarnings("unchecked")
    public LimsAsynctaskServerDao getDao() {
        return limsAsynctaskServerDao;
    }

    @Override
    @Transactional
    @AuditTrailEntry(AuditTrailType.INSERT)
    public String insert(RestJsonWrapperBean jsonWrapper) {
        LimsAsynctaskServerBean limsAsynctaskServer = jsonWrapper.parseUnique(LimsAsynctaskServerBean.class);
        limsAsynctaskServer.setId(ApplicationContextHelper.getNextSequence(getDao().getTable()));
        getDao().insert(limsAsynctaskServer);
        return limsAsynctaskServer.getId();
    }

}
